package com.jizhang.controller;


import com.jizhang.base.model.BaseModel;
import com.jizhang.entity.Info;
import com.jizhang.entity.User;
import com.jizhang.service.InfoService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;


/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 郭博民
 * @since 2022-07-16
 */
@RestController
@RequestMapping("/info")
public class InfoController {
    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
    @Autowired
    InfoService infoService;

    //添加记账
    @ApiOperation(value = "添加一笔", httpMethod = "POST")
    @PostMapping("/addInfo")
    public BaseModel addInfo(@RequestBody Info info, BaseModel baseModel) throws Exception {
        System.out.println("执行添加一笔操作"+df.format(new Date()));
        System.out.println("info:"+info);
        return infoService.addInfo(info, baseModel);
    }

    // 根据月份,类型,进行查询
    //分页查询所有用户
    @ApiOperation(value = "查询支出收入", httpMethod = "POST")
    @PostMapping("/findAll")
    public BaseModel findAllInfo(@RequestBody Info info, BaseModel baseModel) throws Exception {
        System.out.println("查询操作"+df.format(new Date()));
        return infoService.findAllInfo(info,baseModel);
    }
}
